(function () {
  // 步骤1：创建echarts实例
  let myChart = echarts.init(document.querySelector(".pc-l2"));

  // 步骤2：定义配置（指定图表的配置项和数据）
  let option = {
    grid: {
      top: 15,
      left: 40,
      right: 5,
      bottom: 40,
    },
    xAxis: [
      {
        type: "category",
        data: ["北京", "上海", "南京", "苏州", "合肥"],
        axisLine: {
          lineStyle: {
            color: "rgba(147, 160, 173, 1)",
          },
        },
        axisLabel: {
          margin: 10,
          color: "rgba(147, 160, 173, 1)",
          textStyle: {
            fontSize: 14,
          },
        },
        axisTick: {
          show: false,
        },
      },
    ],
    yAxis: [
      {
        axisLabel: {
          color: "rgba(147, 160, 173, 1)",
        },
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        splitLine: {
          show: false,
        },
        max: 3500,
      },
    ],
    series: [
      {
        type: "bar",
        data: [2000, 1520, 1850, 3400, 2756],
        barWidth: "10px",
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0,
              0,
              0,
              1,
              [
                {
                  offset: 0,
                  color: "#f3b043",
                },
                {
                  offset: 1,
                  color: "#e587db",
                },
              ],
              false
            ),
            // shadowColor: 'rgba(0,160,221,1)',
            // shadowBlur: 4,
            barBorderRadius: 1,
            barBorderRadius: 15,
          },
        },
      },
      {
        barGap: "-125%",
        type: "bar",
        data: [3500, 3500, 3500, 3500, 3500],
        barWidth: "15px",
        itemStyle: {
          normal: {
            borderColor: "#504778",
            borderWidth: 1,
            barBorderRadius: 10,
            color: "rgba(255,255,255,0)",
          },
        },
      },
    ],
  };

  // 步骤3：使用刚指定的配置项和数据显示图表
  myChart.setOption(option);

  // 步骤4：监控网页视口
  window.addEventListener("resize", () => {
    myChart.resize();
  });
})();
